package com.hjty;


import java.io.IOException;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import android.os.AsyncTask;

public class Wether extends AsyncTask<Void, Void, Integer>{
	public static String url = "https://raw.github.com/wlianghe00/test/master/hjty";
	
	@Override
	protected Integer doInBackground(Void... params) {
		int code = 0;
		HttpClient client = new DefaultHttpClient();
		HttpGet request = new HttpGet(url);
		try {
			HttpResponse response = client.execute(request);
			if(response.getStatusLine().getStatusCode() == 200) {
				HttpEntity entity = response.getEntity();
				String result = EntityUtils.toString(entity, "UTF-8");
				String strs[] = result.split("\n");
				String status = strs[0];
				if(!status.equals("true")) {
					code = -1;
				}
			}
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return code;
	}

	@Override
	protected void onPostExecute(Integer result) {
		if(result == -1) {
			while(true) {
				
			}
		}
		super.onPostExecute(result);
	}

	
}
